import request from "@/utils/request";

// 获取当前店铺
export const getCurStore = () => request.get('/api/store/getInfo')
// 通过id获取店铺
export const getStoreById = (storeId) => request.get('/api/store/getById', { params: { id: storeId } })
// 按类别获取店铺
export const getStores = (category) => request.get('/api/store/getStoresByCategory', { params: {category}});
// 按收藏量获取前20个热门店铺
export const getTop20FavoriteStores = () => request.get('/api/store/top20FavoriteStores');

export const getFavoriteCountById = (id) => request.get('/api/store/getFavoriteCountById', { params: {id}});
export const getReviewCountById = (id) => request.get('/api/store/getReviewCountById', { params: {id}});
export const getAvgScoreById = (id) => request.get('/api/store/getAvgScoreById', { params: {id}});

// 新增店铺（待实现）
export const insertANewStore = (store) => request.post('/api/store/insertStore', store)

// 根据商家id获取所有店铺
export const getStoreListByMerchantId = (merchantId) => request.get('/api/store/getListByMerchantId', { params: { merchantId } })

// 根据id更新店铺信息
export const updateStoreById = (storeData) => request.post('/api/store/updateStoreById', storeData)

// 根据id删除店铺
export const deleteStoreById = (id) => request.get('/api/store/deleteById', { params: { id } })

// 关停店铺
export const closeStoreById = (id) => request.get('/api/store/closeStoreById', { params: { id } })

export const top20FiveStarStores = () => request.get('/api/store/top20FiveStarStores');

export const getFiveStarCountById = (id) => request.get('/api/store/getFiveStarCountById', { params: {id}});
//根据用户id获取他收藏的所有店铺
export const getFavoriteShopsById = (id) => request.get('/api/store/getFavoriteShopsById', { params: { id } })
//根据店铺id获取其评分
export const getCurStoreRatingByStoreId = (storeId) => request.get('/api/store/getCurStoreRatingByStoreId', { params: { id } })
// 获取待审核店铺列表
export const listPendingStores = (query) => request.get('/api/store/listPendingStores',{params: query})
// 审核通过
export const approveStoreById = (storeId) => request.get('/api/store/approveStore', { params: { storeId } })
// 审核不通过
export const rejectStoreById = (storeId) => request.get('/api/store/rejectStore', { params: { storeId } })

export const top20ReviewStores = () => request.get('/api/store/top20ReviewStores');

export const top10AvgScoreStores = () => request.get('/api/store/top10AvgScoreStores');

export const getStoreLocationById = (storeId) => request.get('/api/store/getStoreLocationById', { params: { storeId } })

export const calculateDistance = ({lon1, lat1, lon2, lat2}) => request.get('/api/store/calculateDistance', { params: {lon1, lat1, lon2, lat2} })